package com.yixun.qfbao.hander;

import com.yixun.qfbao.api.service.PremisesApiService;
import com.yixun.qfbao.apidto.GetPremisesForRuleReqDto;
import com.yixun.qfbao.apidto.GetPremisesForRuleResDto;
import com.yixun.qfbao.dto.base.BaseRequestDTO;
import com.yixun.qfbao.dto.base.BaseResponseDTO;
import com.yixun.qfbao.hander.base.CommonAbstractHander;
import com.yixun.qfbao.vo.GetPremisesForRuleReqVo;
import com.yixun.qfbao.xf.model.enums.ResultEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Description 设置规则获取楼盘
 * @Date 2017/12/5
 * @Author sangtao
 * @Computer Administrator
 */
@Service("getPremisesForRuleHander")
public class GetPremisesForRuleHander extends CommonAbstractHander {
    private static Logger logger= LoggerFactory.getLogger(GetPremisesForRuleHander.class);

    @Autowired
    private PremisesApiService premisesService;

    @SuppressWarnings("rawtypes")
    @Override
    public BaseResponseDTO doBusiness(BaseRequestDTO reqDto) {
        GetPremisesForRuleReqVo req = (GetPremisesForRuleReqVo)reqDto;
        GetPremisesForRuleReqDto reqDto1 = req.getParams();
        BaseResponseDTO<GetPremisesForRuleResDto> res = new BaseResponseDTO<GetPremisesForRuleResDto>();
        GetPremisesForRuleResDto resDto = new GetPremisesForRuleResDto();
        try {
            resDto = premisesService.getPremisesForRule(reqDto1);
        } catch (Exception e) {
            logger.error("GetPremisesForRuleHander error: {}", e);
            resDto.setResult(ResultEnum.FAIL.getNo());
            resDto.setResultMsg("项目获取失败!");
        }
        res.setResData(resDto);
        res.setResult(resDto.getResult());
        return res;
    }
}
